package com.meilai.project.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

@Configuration
public class RabbitConfig {

    @Bean
    @Profile("prod")
    public FanoutExchange fanoutExchange(){
        return new FanoutExchange("meilai.sms.fanout.exchange",true, false);
    }

    @Bean
    @Profile("prod")
    public Queue sendSmsQueue() {
        return new Queue("meilai.sms");
    }

    @Bean
    @Profile("prod")
    public Binding smsBinding(){
        return BindingBuilder.bind(sendSmsQueue()).to(fanoutExchange());
    }
}
